<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#findIdView").hide();
		$("#idBtn").click(function(){
			$("#findPasswordView").hide();
			$("#findIdView").toggle(1000);
		});
		
		$("#findPasswordView").hide();
		$("#passwordBtn").click(function(){
			$("#findIdView").hide();
			$("#findPasswordView").toggle(1000);
		});
		
		$("#findIdView").on("click",":input[name=idResultBtn]",function(){
			var headNum = $("#headNum").val();
			if(headNum == ""){
				alert("번호를 선택해주세요.");
				return false;
			}
			var phone = headNum + $("input[name=memberPhone]").val();
			$.ajax({
				type : "POST",
				url : "${initParam.root}member/findId.moja",
				data: "memberName="+$(":input[name=memberName]").val() + "&phone=" + phone,
				success:function(jsonData){
					if(jsonData=="" || jsonData == null){
						alert("존재하는 아이디가 없습니다.");
					}else{
						alert("아이디 : "+jsonData);
					}			
				}
			});//ajax
		});
		
		$("#findPasswordView").on("click",":input[name=passwordResultBtn]",function(){
			$.ajax({
			type : "POST",
			url : "${initParam.root}member/findPassword.moja",
			data : "memberId1="+$(":input[name=memberId1]").val(),
			dataType : "json",
			success:function(jsonData){
					if(jsonData=="" || jsonData == null){
						alert("존재하는 아이디가 없습니다.");
					}else{
						var password = jsonData.toString();
						var length = jsonData.toString().length;
						var first = password.charAt(length-3);
						var second = password.charAt(length-1);
						var replace1 = password.replace(first, "*");
						var replace2 = replace1.replace(second, "*");
						/* alert(first);
						alert(second);
						alert("replace : " + replace2);
						alert(password); */
						alert("비밀번호 : " + replace2);
					}						
				}
			});//ajax
		});
	});
</script>
	<div id="mainCss" align="center">
	<form>
		<img alt="ID찾기" src="${initParam.root }img/btn3.jpg" id="idBtn" >&nbsp; /&nbsp; 
		<img alt="비밀번호찾기" src="${initParam.root }img/btn4.jpg" id="passwordBtn" >
	</form>
		<!-- <input type="button" name="idBtn" value="Id 찾기"> -->
		<div id="findIdView">
		<br>
			name  &nbsp;<input type="text" name="memberName" size="30">&nbsp;&nbsp;<br>
			phone&nbsp;<select id = "headNum">
				<option value = "">01</option>
				<option value = "">-----</option>
				<option value = "010">010</option>
				<option value = "011">011</option>
				<option value = "016">016</option>
				<option value = "017">017</option>
				<option value = "018">018</option>
				<option value = "019">019</option>
			</select>&nbsp;
			<input type="text" name="memberPhone" size="30">
			<input type="button" name="idResultBtn" value="검색">
		</div>
		<Br><br>
		<div id="findPasswordView">
		<br>
			id <input type="text" name="memberId1" size="30">
			<input type="button" name="passwordResultBtn" value="검색">
		</div>
		<%-- <hr>
		<a href="${initParam.root }member/home.moja">home으로 가용!!!</a> --%>
</div>
	
	
	
	

